<div id="content">
    <div id="content-header">
        <div id="breadcrumb"><a href="<?php echo site_url('Login/login') ?>" title="Go to Home" class="tip-bottom"><i
                class="icon-home"></i> 主页</a> <a href="#" class="current">用户管理</a><a href="#" class="current">新增代理等级</a></div>
        <h1>新增代理等级</h1>
    </div>
    <div class="container-fluid">
        <hr>
        <div class="row-fluid">
            <div class="span8">
                <!--修改数据表单/edit news form-->
                <div class="widget-box">
                    <div class="widget-title"><span class="icon"> <i class="icon-align-justify"></i> </span>
                        <h5>添加等级信息</h5>
                    </div>
                    <div class="widget-content nopadding">
                        <form action="<?php echo site_url('user/addAgentLevel') ?>" method="post" class="form-horizontal">
                            <div class="control-group">
                                <label class="control-label">名称:</label>

                                <div class="controls">
                                    <input type="text" name='level' class="span4" placeholder="请输入名称" required='required'>
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label">返利等级:</label>
                                <div class="controls">
                                    <select name="rLevel" onchange="getRate()">
                                        <?php
                            $rows=$data[0];
                            foreach($rows as $value):
                            ?>
                                        <option value="<?php echo $value['id']?>"><?php echo $value['level']?>
                                        </option>

                                        <?php    endforeach; ?>
                                    </select>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label">返利利率:</label>
                                <div class="controls">
                                    <input type="text" name='ret' class="span4" value="<?php echo $rows[0]['rebate_rate'] ?>"
                                           disabled="disabled">
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label">备注:</label>

                                <div class="controls">
                                    <input type="text" name='des' class="span4" placeholder="请输入备注信息">
                                </div>
                            </div>
                            <div class="form-actions">
                                <button type="submit" class="btn btn-success">保存</button>
                            </div>
                        </form>
                    </div>
                </div>

                <!--修改数据表单/edit news form-->
            </div>
        </div>

    </div>
</div>
<input type="hidden" class="span4" value='<?php echo json_encode($data[0]); ?>'>
<script language="JavaScript">
    function getRate() {
        var $value=$("select[name='rLevel']").val();
        var result = $("input[type='hidden']").val();
        var ret = JSON.parse(result,true);
        for (var i=0;i<ret.length;i++){
            if(ret[i]['id']==$value){
                $("input[name='ret']").val(ret[i]['rebate_rate'])
            }
        }
    }
</script>